﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Objects;
using System.Collections.Generic;
using BAL;

public partial class Admin_UCControls_UCKhachHang_ThongTinKhachHang : System.Web.UI.UserControl
{
    public DanhSachKhachHang ItemDanhSachKhachHang;
    public KhachHang itemKhachHang;

    public static string srtPath;


    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ItemDanhSachKhachHang = new DanhSachKhachHang();
            ItemDanhSachKhachHang = (DanhSachKhachHang)Session["ItemKhachHang"];

            if (ItemDanhSachKhachHang != null)
            {
                itemKhachHang = BALKhachHang.GetById(ItemDanhSachKhachHang.Id);

                GetThongtinKhachHang(itemKhachHang);
                LoadDanhSachKhachHang(ItemDanhSachKhachHang.Id,Convert.ToDateTime(ItemDanhSachKhachHang.NgayDangKy.ToString()));
               
            }
        }
    }

    private void GetThongtinKhachHang(KhachHang khachHang)
    {
        lblHoTen.Text = khachHang.Ten.ToString();
        lblNgaySinh.Text = khachHang.NgaySinh.ToString("dd/MM/yyyy");
        lblSoDienThoai.Text = khachHang.DienThoaiNha.ToString();
        lblCMND.Text = khachHang.CMND.ToString();
        lblDiachi.Text = khachHang.DiaChiLienLac.ToString();
        lblDiaChiThuongTru.Text = khachHang.DiaChiThuongTru.ToString();
        lbldtdd.Text = khachHang.DienThoaiDiDong.ToString();
        lblEmail.Text = khachHang.Email.ToString();
        if (khachHang.GioiTinh.ToString() == "2")
        {
            lblGioitinh.Text = "Nữ";
        }
        else
        {
            lblGioitinh.Text = "Nam";
        }

    }

    public string PathImage()
    {
        return srtPath ="~/images/Generic Card/MauThe";
    }

    public static List<DanhSachThongTinKhachHang> ListThongTinKhachHang;

    public void LoadDanhSachKhachHang(int idKhachHang, DateTime NgayDangKy)
    {

        ListThongTinKhachHang = new List<DanhSachThongTinKhachHang>();
        ListThongTinKhachHang = BALDanhSachThongTinKhachHang.GetAllItem(idKhachHang,NgayDangKy);

        dtlDanhSachKHNhan.DataSource = ListThongTinKhachHang;
        dtlDanhSachKHNhan.DataBind();

    }
}
